<!DOCTYPE html>












  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">









  
  
    
  
  <link rel="stylesheet" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.css">




<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">



















  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.3.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.3.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '6.3.0',
    sidebar: {"position":"left","display":"hide","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="spring boot 属性加载顺序 默认属性(通过SpringApplication.setDefaultProperties设置) @Configuration配置类通过@PropertySource启用的资源文件 配置文件 RandomValuePropertySource 操作系统属性 System.getProperties() JNDI属性(java:comp/env) Servlet">
<meta name="keywords" content="java,springboot">
<meta property="og:type" content="article">
<meta property="og:title" content="Spring Boot 零碎">
<meta property="og:url" content="http://codertang.com/2020/04/27/spring-boot-fragement/index.html">
<meta property="og:site_name" content="Tonny&#39;s Blog">
<meta property="og:description" content="spring boot 属性加载顺序 默认属性(通过SpringApplication.setDefaultProperties设置) @Configuration配置类通过@PropertySource启用的资源文件 配置文件 RandomValuePropertySource 操作系统属性 System.getProperties() JNDI属性(java:comp/env) Servlet">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2021-08-05T07:50:55.641Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Spring Boot 零碎">
<meta name="twitter:description" content="spring boot 属性加载顺序 默认属性(通过SpringApplication.setDefaultProperties设置) @Configuration配置类通过@PropertySource启用的资源文件 配置文件 RandomValuePropertySource 操作系统属性 System.getProperties() JNDI属性(java:comp/env) Servlet">






  <link rel="canonical" href="http://codertang.com/2020/04/27/spring-boot-fragement/">



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>Spring Boot 零碎 | Tonny's Blog</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Tonny's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">莫等闲, 白了少年头, 空悲切</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>
  </li>

      
      
    </ul>
  

  
    

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://codertang.com/2020/04/27/spring-boot-fragement/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tonny Yi">
      <meta itemprop="description" content="Coding, Life, Zen">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Tonny's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Spring Boot 零碎
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2020-04-27 20:06:52" itemprop="dateCreated datePublished" datetime="2020-04-27T20:06:52+08:00">2020-04-27</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2021-08-05 15:50:55" itemprop="dateModified" datetime="2021-08-05T15:50:55+08:00">2021-08-05</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/java/" itemprop="url" rel="index"><span itemprop="name">java</span></a></span>

                
                
                  ，
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/java/framework/" itemprop="url" rel="index"><span itemprop="name">framework</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        <h2 id="spring-boot-属性加载顺序"><a href="#spring-boot-属性加载顺序" class="headerlink" title="spring boot 属性加载顺序"></a>spring boot 属性加载顺序</h2><ol>
<li>默认属性(通过<code>SpringApplication.setDefaultProperties</code>设置)</li>
<li><code>@Configuration</code>配置类通过<code>@PropertySource</code>启用的资源文件</li>
<li><strong>配置文件</strong></li>
<li><code>RandomValuePropertySource</code></li>
<li>操作系统属性</li>
<li><code>System.getProperties()</code></li>
<li>JNDI属性(<code>java:comp/env</code>)</li>
<li><code>ServletContext</code>初始化参数</li>
<li><code>ServletConfig</code>初始化参数</li>
<li><code>SPRING_APPLICATION_JSON</code></li>
<li>命令行参数</li>
<li>单元测试时<code>@SpringBootTest</code>配置的属性</li>
<li>单元测试时<code>@TestPropertySource</code>启用的属性</li>
<li>devtools使用的<code>$HOME/.config/spring-boot</code>目录下的文件</li>
</ol>
<h2 id="spring-boot-配置文件加载顺序"><a href="#spring-boot-配置文件加载顺序" class="headerlink" title="spring boot 配置文件加载顺序"></a>spring boot 配置文件加载顺序</h2><blockquote>
<p><a href="https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config.files" target="_blank" rel="noopener">https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config.files</a></p>
</blockquote>
<p>spring boot默认会按照以下顺序, 在下面的文件夹中查找配置文件(优先级由低到高):</p>
<ol>
<li>classpath根目录</li>
<li>classpath下的<code>/config</code>文件夹</li>
<li>启动目录</li>
<li>启动目录下的<code>/config</code>文件夹</li>
<li>启动目录下的<code>/config</code>文件夹的子文件夹</li>
</ol>
<ul>
<li><p><strong>启动目录</strong>指的是你在哪个目录下启动的应用, 举例来说: 应用包<code>user-center-1.0.0.jar</code>在<code>/home/test/app/</code>下</p>
<ol>
<li><p>如果在<code>/home/test/app/</code>下执行<code>java -jar user-center-1.0.0.jar</code>, 那么<strong>启动目录</strong>就是<code>/home/test/app/</code></p>
</li>
<li><p>如果在<code>/home/test/</code>下执行<code>java -jar app/user-center-1.0.0.jar</code>, 那么<strong>启动目录</strong>就是<code>/home/test/</code></p>
</li>
</ol>
</li>
<li><p><strong>classpath</strong>可以简单理解为应用的<code>resource</code>目录</p>
</li>
</ul>
<p>spring可以通过命令行参数<strong><code>spring.config.location</code></strong>自定义配置文件加载顺序, 如: <code>java -Dspring.config.location=classpath:/properties/,file:./properties/ -jar user-center-1.0.0.jar</code>, <strong>spring会完全按照这个配置进行查找</strong>, 配置文件加载顺序会变成下面这样:</p>
<ol>
<li><code>file:./properties/</code></li>
<li><code>classpath:properties/</code></li>
</ol>
<p>另外, spring还可以通过命令行参数<strong><code>spring.config.additional-location</code></strong>指定额外的配置文件路径, 如: <code>java -Dspring.config.additional-location=classpath:/custom-config/,file:./custom-config/ -jar user-center-1.0.0.jar</code>, 那么配置文件加载顺序就变成了:</p>
<ol>
<li><code>file:./custom-config/</code></li>
<li><code>classpath:custom-config/</code></li>
<li><code>file:./config/</code></li>
<li><code>file:./</code></li>
<li><code>classpath:/config/</code></li>
<li><code>classpath:/</code></li>
</ol>
<p>需要注意的是, 如果一个配置项在多个文件都定义了, 则<strong>先定义的优先级更高</strong>, 所以应用<code>resource</code>下的配置文件优先级最高</p>
<h2 id="profile配置文件加载"><a href="#profile配置文件加载" class="headerlink" title="profile配置文件加载"></a>profile配置文件加载</h2><blockquote>
<p><a href="https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-profile-specific-properties" target="_blank" rel="noopener">https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-profile-specific-properties</a></p>
</blockquote>
<p>spring中可以使用<code>application-{profile}.properties</code>配置作为<code>application.properties</code>配置的补充, 如果没有配置要激活的profile, 则spring会加载<code>application-default.properties</code>配置文件. </p>
<p><strong>指定<code>application-{profile}.properties</code>的优先级高于<code>application.properties</code></strong>, 而且如果激活了多个profile, 则后面的profile会覆盖前者, 这条规则比上面文件目录规则优先级更高, 比如<code>java -jar -Dspring.profiles.active=prod user-center-1.0.0jar</code>启动应用. 结合目录加载顺序, 一个配置项的优先级如下:</p>
<ol>
<li><code>file:./config/spring-prod.properties</code></li>
<li><code>file:./spring-prod.properties</code></li>
<li><code>classpath:/config/spring-prod.properties</code></li>
<li><code>classpath:spring-prod.properties</code></li>
<li><code>file:./config/spring.properties</code></li>
<li><code>file:./spring.properties</code></li>
<li><code>classpath:/config/spring.properties</code></li>
<li><code>classpath:spring.properties</code></li>
</ol>
<p><strong>profile优先级最高, 其次先外部再内部, 然后config目录, 最后是默认配置</strong></p>
<h2 id="配置参数加载顺序"><a href="#配置参数加载顺序" class="headerlink" title="配置参数加载顺序"></a>配置参数加载顺序</h2><blockquote>
<p><a href="https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config" target="_blank" rel="noopener">https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config</a></p>
</blockquote>
<p>spring中通过<code>${xxx}</code>加载变量时, 会从多个位置查找这个配置项, 具体顺序如下(不完整, 只保留运行时需要关心的):</p>
<ol>
<li>命令行</li>
<li><code>ServletConfig</code>初始化参数</li>
<li><code>ServletContext</code>初始化参数</li>
<li><code>System.getProperties()</code></li>
<li>操作系统环境变量</li>
<li>外部目录下的<code>application-{profile}.properties</code>文件</li>
<li><code>classpath</code>下的<code>application-{profile}.properties</code>文件</li>
<li>外部目录的<code>application.properties</code></li>
<li><code>classpath</code>下的<code>application.properties</code>文件</li>
<li>应用内使用<code>@PropertySource</code>的配置类(<code>@Configuration</code>)</li>
</ol>
<h2 id="序列化LocalDateTime成数组问题"><a href="#序列化LocalDateTime成数组问题" class="headerlink" title="序列化LocalDateTime成数组问题"></a>序列化LocalDateTime成数组问题</h2><h3 id="问题表现"><a href="#问题表现" class="headerlink" title="问题表现"></a>问题表现</h3><p>在JDK8之前, 后端如果想将日期格式的JSON数据转成时间戳返回给前端, 只需要在配置文件中增加如下配置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 返回时间戳</span><br><span class="line">spring.jackson.serialization.write-dates-as-timestamps=true</span><br></pre></td></tr></table></figure>
<p>使用<code>@responseBody</code>返回json数据时，会自动将时间格式化为毫秒值。</p>
<p>但是在使用了<code>LocalDateTime</code>后, 返回的数据格式成了这样<code>&quot;createTime&quot;:[2020,6,9,15,47,29]</code>, 上面的配置没有失效了. 对此官方文档的说明如下: <a href="https://github.com/FasterXML/jackson-modules-java8/tree/master/datetime" target="_blank" rel="noopener">jackson-modules-java8</a></p>
<blockquote>
<p><a href="https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html" target="_blank" rel="noopener"><code>LocalDate</code></a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/time/LocalTime.html" target="_blank" rel="noopener"><code>LocalTime</code></a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html" target="_blank" rel="noopener"><code>LocalDateTime</code></a>, and <a href="https://docs.oracle.com/javase/8/docs/api/java/time/OffsetTime.html" target="_blank" rel="noopener"><code>OffsetTime</code></a>, which cannot portably be converted to timestamps and are instead represented as arrays when <code>WRITE_DATES_AS_TIMESTAMPS</code> is enabled.</p>
</blockquote>
<h3 id="解决办法"><a href="#解决办法" class="headerlink" title="解决办法"></a>解决办法</h3><ol>
<li><p>自定义<code>JsonSerialize</code></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">LocalDateTimeConverter</span> <span class="keyword">extends</span> <span class="title">JsonSerializer</span>&lt;<span class="title">LocalDateTime</span>&gt; </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">serialize</span><span class="params">(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)</span> <span class="keyword">throws</span> IOException </span>&#123;</span><br><span class="line">        gen.writeNumber(value.toInstant(ZoneOffset.of(<span class="string">"+8"</span>)).toEpochMilli());</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>在实体类时间属性上，加入<code>@JsonSerialize(using = LocalDateTimeConverter.class)</code>注解即可</p>
</li>
</ol>
<h3 id="发序列化问题"><a href="#发序列化问题" class="headerlink" title="发序列化问题"></a>发序列化问题</h3>
      
    </div>

    

    
    
    

    

    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>Tonny Yi</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://codertang.com/2020/04/27/spring-boot-fragement/" title="Spring Boot 零碎">http://codertang.com/2020/04/27/spring-boot-fragement/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc/4.0/" rel="external nofollow" target="_blank">CC BY-NC 4.0</a> 许可协议。转载请注明出处！</li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/java/" rel="tag"># java</a>
          
            <a href="/tags/springboot/" rel="tag"># springboot</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/11/12/loading-resource/" rel="next" title="java 中资源文件的加载方式">
                <i class="fa fa-chevron-left"></i> java 中资源文件的加载方式
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/05/08/logger-level-modifier/" rel="prev" title="动态调整日志级别">
                动态调整日志级别 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.png" alt="Tonny Yi">
            
              <p class="site-author-name" itemprop="name">Tonny Yi</p>
              <p class="site-description motion-element" itemprop="description">Coding, Life, Zen</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">49</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">42</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">59</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/tonnyyi" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:tonnyemails@gmail.com" target="_blank" title="E-Mail"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  
                </span>
              
            </div>
          

          
          
            <div class="cc-license motion-element" itemprop="license">
              <a href="https://creativecommons.org/licenses/by-nc/4.0/" class="cc-opacity" target="_blank">
                <img src="/images/cc-by-nc.svg" alt="Creative Commons">
              </a>
            </div>
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#spring-boot-属性加载顺序"><span class="nav-number">1.</span> <span class="nav-text">spring boot 属性加载顺序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#spring-boot-配置文件加载顺序"><span class="nav-number">2.</span> <span class="nav-text">spring boot 配置文件加载顺序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#profile配置文件加载"><span class="nav-number">3.</span> <span class="nav-text">profile配置文件加载</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置参数加载顺序"><span class="nav-number">4.</span> <span class="nav-text">配置参数加载顺序</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#序列化LocalDateTime成数组问题"><span class="nav-number">5.</span> <span class="nav-text">序列化LocalDateTime成数组问题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#问题表现"><span class="nav-number">5.1.</span> <span class="nav-text">问题表现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解决办法"><span class="nav-number">5.2.</span> <span class="nav-text">解决办法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#发序列化问题"><span class="nav-number">5.3.</span> <span class="nav-text">发序列化问题</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Tonny Yi</span>

  

  
</div>


  <script src="https://unpkg.com/mermaid@7.1.2/dist/mermaid.min.js"></script>
  <script>
    if (window.mermaid) {
      mermaid.initialize("");
    }
  </script>





  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Mist</a></div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.3.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.3.0"></script>



  



	





  





  










  





  

  

  

  

  
  

  

  

  

  

  
  <style>
    .copy-btn {
      display: inline-block;
      padding: 6px 12px;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;
      color: #333;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background-color: #eee;
      background-image: linear-gradient(#fcfcfc, #eee);
      border: 1px solid #d5d5d5;
      border-radius: 3px;
      user-select: none;
      outline: 0;
    }

    .highlight-wrap .copy-btn {
      transition: opacity .3s ease-in-out;
      opacity: 0;
      padding: 2px 6px;
      position: absolute;
      right: 4px;
      top: 8px;
    }

    .highlight-wrap:hover .copy-btn,
    .highlight-wrap .copy-btn:focus {
      opacity: 1
    }

    .highlight-wrap {
      position: relative;
    }
  </style>
  <script>
    $('.highlight').each(function (i, e) {
      var $wrap = $('<div>').addClass('highlight-wrap')
      $(e).after($wrap)
      $wrap.append($('<button>').addClass('copy-btn').append('复制').on('click', function (e) {
        var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
          return $(e).text()
        }).toArray().join('\n')
        var ta = document.createElement('textarea')
        document.body.appendChild(ta)
        ta.style.position = 'absolute'
        ta.style.top = '0px'
        ta.style.left = '0px'
        ta.value = code
        ta.select()
        ta.focus()
        var result = document.execCommand('copy')
        document.body.removeChild(ta)
        
          if(result)$(this).text('复制成功')
          else $(this).text('复制失败')
        
        $(this).blur()
      })).on('mouseleave', function (e) {
        var $b = $(this).find('.copy-btn')
        setTimeout(function () {
          $b.text('复制')
        }, 300)
      }).append(e)
    })
  </script>


</body>
</html>
